package com.gss.armory.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.springframework.beans.factory.annotation.Autowired;

@Entity
@Table(name = "LOCATION_DETAILS")
public class LocationDetailsDTO implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3029906907207497810L;


	@Autowired
	BusinessUnitTypeDTO businessUnitTypeDTO;
	
	
	private long ldId;
	private String ldName;
	private String ldCode;
	private String ldType;
	private CompanyDetailsDTO ldCompanyId;
	private LocationDetailsDTO parentLoc;
	private List<DepartmentDetailsDTO> departmentDetailsDTOs;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="LD_ID")
	public long getLdId() {
		return ldId;
	}
	@Column(name="LD_NAME",length=101,nullable=false)
	public String getLdName() {
		return ldName;
	}
	@Column(name="LD_TYPE",length=51)
	public String getLdType() {
		return ldType;
	}
	@ManyToOne(targetEntity=CompanyDetailsDTO.class)
	@JoinColumn(name="LD_COMPANY_ID",nullable=false)
	public CompanyDetailsDTO getLdCompanyId() {
		return ldCompanyId;
	}
	
	public void setLdId(long ldId) {
		this.ldId = ldId;
	}
	public void setLdName(String ldName) {
		this.ldName = ldName;
	}
	public void setLdType(String ldType) {
		this.ldType = ldType;
	}
	public void setLdCompanyId(CompanyDetailsDTO ldCompanyId) {
		this.ldCompanyId = ldCompanyId;
	}
	@ManyToOne
	@JoinTable(name="DM_LOCS_GROUPING",joinColumns= @JoinColumn(name="LGM_CHILD_LOC_ID"),inverseJoinColumns = @JoinColumn(name="LGM_PARENT_LOC_ID"))
	public LocationDetailsDTO getParentLoc() {
		return parentLoc;
	}
	public void setParentLoc(LocationDetailsDTO parentLoc) {
		this.parentLoc = parentLoc;
	}
	@Column(name="LD_CODE",length=21,nullable=false)
	public String getLdCode() {
		return ldCode;
	}
	
	public void setLdCode(String ldCode) {
		this.ldCode = ldCode;
	}
	
	@ManyToMany(targetEntity=DepartmentDetailsDTO.class,fetch=FetchType.EAGER)
	@JoinTable(name="LOC_DEPARTMENT_MAPPING",
			joinColumns=@JoinColumn(name="LDM_LOC_ID"),
			inverseJoinColumns=@JoinColumn(name="LDM_DEPT_ID"))
	public List<DepartmentDetailsDTO> getDepartmentDetailsDTOs() {
		return departmentDetailsDTOs;
	}
	
	public void setDepartmentDetailsDTOs(List<DepartmentDetailsDTO> departmentDetailsDTOs) {
		this.departmentDetailsDTOs = departmentDetailsDTOs;
	}
}